package com.yy.user;

import com.yy.user.Premission;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity
@Table(name="t_role")
public class Role implements Serializable{
	
	private static final long serialVersionUID = -3279947501157474505L;
	@Id
	@GeneratedValue
	private Long id;
	
	private String roleName;
	
	private String description;
	
	private Boolean available = false;
	
	@ManyToMany
	@JoinTable(name="t_user_role",joinColumns={@JoinColumn(name="roleId")},
	inverseJoinColumns={@JoinColumn(name="userId")})
	private List<User> users;
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="t_role_premission",joinColumns={@JoinColumn(name="roleId")},
	inverseJoinColumns={@JoinColumn(name="premissionId")})
	private List<Premission> premissions;
	
	public Role() {
		super();
	}
	
	public Role(Long id, String roleName, String description, Boolean available, List<User> users,
			List<Premission> premissions) {
		super();
		this.id = id;
		this.roleName = roleName;
		this.description = description;
		this.available = available;
		this.users = users;
		this.premissions = premissions;
	}


	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getRoleName() {
		return roleName;
	}
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Boolean getAvailable() {
		return available;
	}
	public void setAvailable(Boolean available) {
		this.available = available;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public List<Premission> getPremissions() {
		return premissions;
	}
	public void setPremissions(List<Premission> premissions) {
		this.premissions = premissions;
	}

}
